<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    姓名为：<span class="name">name</span>
</body>
<script>

    const obj = {
        nameValue:"admin",
        nameEle:document.querySelector(".name"),
        get name(){
            console.log("有人访问了name属性");
            this.nameEle.innerHTML = this.nameValue;
            return this.nameValue;
        },
        set name(val){
            console.log("有人修改了name，修改为：" + val);
            this.nameValue = val;
            this.nameEle.innerHTML = val;
        }
    }

    obj.name;

    obj.name = "root";

    // const obj = {name:"admin"}
    // const name = document.querySelector(".name");
    // name.innerHTML = obj.name;

    
</script>
</html>